[AS3] Calling Php Script with UTF-8 POST variables

Posted by kornelijepetak on Stack Overflow See other posts from Stack Overflow or by kornelijepetak
Published on 2010-06-08T10:04:45Z Indexed on 2010/06/08 10:12 UTC
Read the original article Hit count: 225

Filed under:
|
|
|
|

AS3 documentation says that Strings in AS3 are in UTF-16 format.

There is a textbox on a Flash Clip where user can type some data.

When a button is clicked, I want this data to be sent to a php script.

I have everything set up, but it seems that the PHP script gets the data in UTF-16 format. The data in the database (which is utf-8) shows some unrecognizable characters (where special characters are used), meaning that the data has not been sent in a correct encoding.

var variables:URLVariables=new URLVariables;

var varSend:URLRequest=new URLRequest("http://website.com/systematic/accept.php");
varSend.method=URLRequestMethod.POST;
varSend.data=variables;

var varLoader:URLLoader=new URLLoader;
varLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);

When submit button is clicked, the following handler gets executed.

function sendData(event:MouseEvent) : void {
    // i guess here is the problem (tbName.text is UTF-16)
    variables.name = tbName.text;

    varLoader.load(varSend);
}

Is there any way to send the data so that PHP script gets the data in UTF-8 format?

(PHP script is retrieving the value using the $_POST['name']).

© Stack Overflow or respective owner

Related posts about php

Related posts about flash